package com.teach.controller;


import com.teach.dto.ResponseEntityDto;
import com.teach.dto.TbCreateOrderDto;
import com.teach.service.TbOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 注释 :  lenovo
 *
 * @author 罗帅哲
 * @version 1.0.0
 * @ClassName OrderController.java  / educate
 * @Description TODO
 * @createTime 2022年10月02日 16:09创建
 */
@RestController
@RequestMapping("/order")
@Api(tags = "订单接口")
@Slf4j
public class OrderController {
    @Resource
    TbOrderService tbOrderService;



    @PostMapping("/createorder")
    @ApiOperation("生成订单表")
    public ResponseEntityDto createorder(@RequestBody TbCreateOrderDto tbCourseBase, HttpServletRequest request){
         String token = request.getHeader("token");
         if(StringUtils.isBlank(token)){
             return new ResponseEntityDto(null,5000,"请先登录",false);
         }

        return tbOrderService.createorder(tbCourseBase,token);
    }

}
